/*
\ * 文件名：cityInfoController.java	 
 * 时     间：下午4:20:10
 * 作     者：liyf       
 * 版     权： 2014-2022  智慧园区, 公司保留所有权利.
 * 联     系：www.szyungu.com
 */
package com.cz073586.technology.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.cz073586.common.contants.CommonContans;
import com.cz073586.common.controller.BaseController;
import com.cz073586.common.entity.pojo.PageInfo;
import com.cz073586.technology.model.CityInfo;
import com.cz073586.technology.service.face.CityInfoService;
import com.cz073586.tools.privilege.ResourceAndOperate;
import com.cz073586.tools.util.UUIDGenerateUtil;

/**
 * @ClassName: cityInfoController
 * @Description: 这里用一句话描述这个类的作用
 * @author zengqj
 * @date 2015年1月20日 下午4:20:10
 */
@RestController
@RequestMapping(value = "/cityManager", method = RequestMethod.POST)
@ResourceAndOperate(
		moduleID = "com.technology.city", 
		moduleName = "城市管理", 
		resouceDesc = "城市管理",
		parentModuleID = "com.technology", 
		parentModuleName = "昱显科技项目"
		)
public class CityInfoController extends BaseController
{
	@Autowired
	private CityInfoService cityInfoService;
	
	/**
	 * 
	 * @方法名称: queryServicesByPage
	 * @描述: 查询城市列表
	 *
	 * @参数:
	 * @param page
	 * @return
	 *
	 * @返回类型: ModelMap
	 * @作者:zengqj
	 * @可能抛出异常:
	 */
	@RequestMapping(value = "/queryCityByPage.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	@ResourceAndOperate(
			moduleID = "com.technology.city.queryCityListByPage", 
			moduleName = "通过分页对象查询", 
			resouceDesc = "查询分页",
			parentModuleID = "com.technology.city", 
			parentModuleName = "城市管理"
			)
	public ModelMap queryCityListByPage(@RequestBody PageInfo<CityInfo> page)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			cityInfoService.queryByPage(page);
			resultMap.put(CommonContans.STRUTS_DATA, page);
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	/**
	 * 
	 * 方法描述：查询所有城市信息
	 * @Title: queryAllCity 
	 * @param @return
	 * @return ModelMap
	 * @user Administrator
	 * 2015年1月25日
	 * @throws
	 */
	@RequestMapping(value = "/queryAllCity.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	@ResourceAndOperate(
			moduleID = "com.technology.city.queryAllCity", 
			moduleName = "查询所有城市信息", 
			resouceDesc = "查询所有城市信息",
			parentModuleID = "com.technology.city", 
			parentModuleName = "城市管理"
			)
	public ModelMap queryAllCity()
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			
			resultMap.put(CommonContans.STRUTS_DATA, cityInfoService.queryAllCity());
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	/**
	 * 
	 * @方法名称: querycityById
	 * @描述: 通过城市ID查询
	 *
	 * @参数:
	 * @param cityId
	 * @return
	 *
	 * @返回类型: ModelMap
	 * @作者:zengqj
	 * @可能抛出异常:
	 */
	@RequestMapping(value = "/queryCityById.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	@ResourceAndOperate(
			moduleID = "com.technology.city.querycityById", 
			moduleName = "查询单一城市", 
			resouceDesc = "通过ID查询城市",
			parentModuleID = "com.technology.city", 
			parentModuleName = "城市管理"
			)
	public ModelMap querycityById(String cityId)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			
			resultMap.put(CommonContans.STRUTS_DATA,
					cityInfoService.selectByPrimaryKey(cityId));
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	/**
	 * 
	 * 方法描述：添加城市信息，uuid由代码写入
	 * 
	 * @Title: insertcity
	 * @param @param city
	 * @param @return
	 * @return ModelMap
	 * @city Administrator 2015年1月21日
	 * @throws
	 */
	@RequestMapping(value = "/insertCity.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	@ResourceAndOperate(
			moduleID = "com.technology.city.insertcity", 
			moduleName = "添加", 
			resouceDesc = "添加城市",
			parentModuleID = "com.technology.city", 
			parentModuleName = "城市管理"
			)
	public ModelMap insertcity(@RequestBody CityInfo city)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			city.setUuid(UUIDGenerateUtil.generate());
			resultMap.put(CommonContans.STRUTS_DATA,
					cityInfoService.insert(city));
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	/**
	 * 
	 * 方法描述：根据city主机修改城市信息
	 * 
	 * @Title: updatecity
	 * @param @param city
	 * @param @return
	 * @return ModelMap
	 * @city Administrator 2015年1月21日
	 * @throws
	 */
	@RequestMapping(value = "/updateCity.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	@ResourceAndOperate(
			moduleID = "com.technology.city.updatecity", 
			moduleName = "修改", 
			resouceDesc = "修改",
			parentModuleID = "com.technology.city", 
			parentModuleName = "城市管理"
			)
	public ModelMap updatecity(@RequestBody CityInfo city)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			resultMap.put(CommonContans.STRUTS_DATA,
					cityInfoService.updateByPrimaryKeySelective(city));
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	/**
	 * 
	 * 方法描述：根据主键删除城市
	 * 
	 * @Title: deletecity
	 * @param @param cityId
	 * @param @return
	 * @return ModelMap
	 * @city Administrator 2015年1月21日
	 * @throws
	 */
	@RequestMapping(value = "/deleteCity.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	@ResourceAndOperate(
			moduleID = "com.technology.city.deletecity", 
			moduleName = "删除", 
			resouceDesc = "删除",
			parentModuleID = "com.technology.city", 
			parentModuleName = "城市管理"
			)
	public ModelMap deleteCity(String cityId)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			resultMap.put(CommonContans.STRUTS_DATA,
					cityInfoService.deleteByPrimaryKey(cityId));
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
}
